<template>
  <div class="select-table">
    <PageTable :columns="columns" :data="goodsTable" />
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
import { GOODS_SATAUS_NAME } from '@/enum/goods'
export default {
  name: 'GoodsTable',
  props: {
    goodsTable: Array
  },
  data() {
    return {
      columns: [
        {
          label: '商品',
          render: (h, { row }) => {
            return (
              <div class="flex">
                <img
                  style={'width: 60px;height: 60px;'}
                  src={row.mainGraph}
                  previewSrcList={[row.mainGraph]}
                />
                <div class="ml-10 flex flex-col justify-between">{row.name}</div>
              </div>
            )
          }
        },
        {
          prop: 'supplierName',
          label: '所属供应商'
        },
        {
          label: '兑换积分',
          render: (h, { row }) => {
            return <div>{`${row.minPrice}-${row.maxPrice}`}</div>
          }
        },
        {
          label: '状态',
          render: (h, { row }) => {
            return <div>{GOODS_SATAUS_NAME[row.sellType]}</div>
          }
        },
        {
          label: '操作',
          render: () => {
            return (
              <PopConfirm text={'确认删除该sh吗？'} confirm={() => this.deleteGoods()}>
                <el-button type="text">删除</el-button>
              </PopConfirm>
            )
          }
        }
      ]
    }
  },
  created() {},
  mounted() {},
  methods: {
    ...mapMutations('base', ['RESET_POINT_SELECT']),
    deleteGoods() {
      this.RESET_POINT_SELECT()
    }
  }
}
</script>

<style lang="scss" scoped></style>
